/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package net.jonbuck.tassoo.model.provider;

import java.util.ArrayList;
import java.util.Collection;

import net.jonbuck.tassoo.model.util.TassooAdapterFactory;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.provider.ChangeNotifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChangeNotifier;
import org.eclipse.emf.edit.provider.IDisposable;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemColorProvider;
import org.eclipse.emf.edit.provider.IItemFontProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertySource;
import org.eclipse.emf.edit.provider.INotifyChangedListener;
import org.eclipse.emf.edit.provider.IStructuredItemContentProvider;
import org.eclipse.emf.edit.provider.ITableItemColorProvider;
import org.eclipse.emf.edit.provider.ITableItemFontProvider;
import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;

/**
 * This is the factory that is used to provide the interfaces needed to support Viewers.
 * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}.
 * The adapters also support Eclipse property sheets.
 * Note that most of the adapters are shared among multiple instances.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public class TassooItemProviderAdapterFactory extends TassooAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable {
	/**
	 * This keeps track of the root adapter factory that delegates to this adapter factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ComposedAdapterFactory parentAdapterFactory;

	/**
	 * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected IChangeNotifier changeNotifier = new ChangeNotifier();

	/**
	 * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected Collection<Object> supportedTypes = new ArrayList<Object>();

	/**
	 * This constructs an instance.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TassooItemProviderAdapterFactory() {
		supportedTypes.add(IEditingDomainItemProvider.class);
		supportedTypes.add(IStructuredItemContentProvider.class);
		supportedTypes.add(ITreeItemContentProvider.class);
		supportedTypes.add(IItemLabelProvider.class);
		supportedTypes.add(IItemPropertySource.class);
		supportedTypes.add(ITableItemLabelProvider.class);
		supportedTypes.add(ITableItemColorProvider.class);
		supportedTypes.add(ITableItemFontProvider.class);
		supportedTypes.add(IItemColorProvider.class);
		supportedTypes.add(IItemFontProvider.class);
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.Attachment} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AttachmentItemProvider attachmentItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.Attachment}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createAttachmentAdapter() {
		if (attachmentItemProvider == null) {
			attachmentItemProvider = new AttachmentItemProvider(this);
		}

		return attachmentItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.AttachmentType} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AttachmentTypeItemProvider attachmentTypeItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.AttachmentType}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createAttachmentTypeAdapter() {
		if (attachmentTypeItemProvider == null) {
			attachmentTypeItemProvider = new AttachmentTypeItemProvider(this);
		}

		return attachmentTypeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.AttachmentTypes} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AttachmentTypesItemProvider attachmentTypesItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.AttachmentTypes}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createAttachmentTypesAdapter() {
		if (attachmentTypesItemProvider == null) {
			attachmentTypesItemProvider = new AttachmentTypesItemProvider(this);
		}

		return attachmentTypesItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.AttachmentContainer} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AttachmentContainerItemProvider attachmentContainerItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.AttachmentContainer}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createAttachmentContainerAdapter() {
		if (attachmentContainerItemProvider == null) {
			attachmentContainerItemProvider = new AttachmentContainerItemProvider(this);
		}

		return attachmentContainerItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.BaseObject} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected BaseObjectItemProvider baseObjectItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.BaseObject}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createBaseObjectAdapter() {
		if (baseObjectItemProvider == null) {
			baseObjectItemProvider = new BaseObjectItemProvider(this);
		}

		return baseObjectItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.Categories} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CategoriesItemProvider categoriesItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.Categories}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createCategoriesAdapter() {
		if (categoriesItemProvider == null) {
			categoriesItemProvider = new CategoriesItemProvider(this);
		}

		return categoriesItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.Category} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CategoryItemProvider categoryItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.Category}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createCategoryAdapter() {
		if (categoryItemProvider == null) {
			categoryItemProvider = new CategoryItemProvider(this);
		}

		return categoryItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.Comment} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CommentItemProvider commentItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.Comment}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createCommentAdapter() {
		if (commentItemProvider == null) {
			commentItemProvider = new CommentItemProvider(this);
		}

		return commentItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.Container} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ContainerItemProvider containerItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.Container}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createContainerAdapter() {
		if (containerItemProvider == null) {
			containerItemProvider = new ContainerItemProvider(this);
		}

		return containerItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.Containers} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ContainersItemProvider containersItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.Containers}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createContainersAdapter() {
		if (containersItemProvider == null) {
			containersItemProvider = new ContainersItemProvider(this);
		}

		return containersItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.Priority} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PriorityItemProvider priorityItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.Priority}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createPriorityAdapter() {
		if (priorityItemProvider == null) {
			priorityItemProvider = new PriorityItemProvider(this);
		}

		return priorityItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.Priorities} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected PrioritiesItemProvider prioritiesItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.Priorities}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createPrioritiesAdapter() {
		if (prioritiesItemProvider == null) {
			prioritiesItemProvider = new PrioritiesItemProvider(this);
		}

		return prioritiesItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.Recurrence} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected RecurrenceItemProvider recurrenceItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.Recurrence}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createRecurrenceAdapter() {
		if (recurrenceItemProvider == null) {
			recurrenceItemProvider = new RecurrenceItemProvider(this);
		}

		return recurrenceItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.ReferenceModel} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ReferenceModelItemProvider referenceModelItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.ReferenceModel}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createReferenceModelAdapter() {
		if (referenceModelItemProvider == null) {
			referenceModelItemProvider = new ReferenceModelItemProvider(this);
		}

		return referenceModelItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.Status} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected StatusItemProvider statusItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.Status}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createStatusAdapter() {
		if (statusItemProvider == null) {
			statusItemProvider = new StatusItemProvider(this);
		}

		return statusItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.Statuses} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected StatusesItemProvider statusesItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.Statuses}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createStatusesAdapter() {
		if (statusesItemProvider == null) {
			statusesItemProvider = new StatusesItemProvider(this);
		}

		return statusesItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.Task} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TaskItemProvider taskItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.Task}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createTaskAdapter() {
		if (taskItemProvider == null) {
			taskItemProvider = new TaskItemProvider(this);
		}

		return taskItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.Tassoo} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TassooItemProvider tassooItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.Tassoo}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createTassooAdapter() {
		if (tassooItemProvider == null) {
			tassooItemProvider = new TassooItemProvider(this);
		}

		return tassooItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.Type} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TypeItemProvider typeItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.Type}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createTypeAdapter() {
		if (typeItemProvider == null) {
			typeItemProvider = new TypeItemProvider(this);
		}

		return typeItemProvider;
	}

	/**
	 * This keeps track of the one adapter used for all {@link net.jonbuck.tassoo.model.Types} instances.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TypesItemProvider typesItemProvider;

	/**
	 * This creates an adapter for a {@link net.jonbuck.tassoo.model.Types}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Adapter createTypesAdapter() {
		if (typesItemProvider == null) {
			typesItemProvider = new TypesItemProvider(this);
		}

		return typesItemProvider;
	}

	/**
	 * This returns the root adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ComposeableAdapterFactory getRootAdapterFactory() {
		return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory();
	}

	/**
	 * This sets the composed adapter factory that contains this factory.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) {
		this.parentAdapterFactory = parentAdapterFactory;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean isFactoryForType(Object type) {
		return supportedTypes.contains(type) || super.isFactoryForType(type);
	}

	/**
	 * This implementation substitutes the factory itself as the key for the adapter.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated_not
	 */
	@Override
	public Adapter adapt(Notifier notifier, Object type) {
		if (notifier instanceof EObject) {
			return super.adapt(notifier, this);
		}
		return null;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object adapt(Object object, Object type) {
		if (isFactoryForType(type)) {
			Object adapter = super.adapt(object, type);
			if (!(type instanceof Class<?>) || (((Class<?>)type).isInstance(adapter))) {
				return adapter;
			}
		}

		return null;
	}

	/**
	 * This adds a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void addListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.addListener(notifyChangedListener);
	}

	/**
	 * This removes a listener.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void removeListener(INotifyChangedListener notifyChangedListener) {
		changeNotifier.removeListener(notifyChangedListener);
	}

	/**
	 * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void fireNotifyChanged(Notification notification) {
		changeNotifier.fireNotifyChanged(notification);

		if (parentAdapterFactory != null) {
			parentAdapterFactory.fireNotifyChanged(notification);
		}
	}

	/**
	 * This disposes all of the item providers created by this factory. 
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void dispose() {
		if (attachmentItemProvider != null) attachmentItemProvider.dispose();
		if (attachmentTypeItemProvider != null) attachmentTypeItemProvider.dispose();
		if (attachmentTypesItemProvider != null) attachmentTypesItemProvider.dispose();
		if (attachmentContainerItemProvider != null) attachmentContainerItemProvider.dispose();
		if (baseObjectItemProvider != null) baseObjectItemProvider.dispose();
		if (categoriesItemProvider != null) categoriesItemProvider.dispose();
		if (categoryItemProvider != null) categoryItemProvider.dispose();
		if (commentItemProvider != null) commentItemProvider.dispose();
		if (containerItemProvider != null) containerItemProvider.dispose();
		if (containersItemProvider != null) containersItemProvider.dispose();
		if (priorityItemProvider != null) priorityItemProvider.dispose();
		if (prioritiesItemProvider != null) prioritiesItemProvider.dispose();
		if (recurrenceItemProvider != null) recurrenceItemProvider.dispose();
		if (referenceModelItemProvider != null) referenceModelItemProvider.dispose();
		if (statusItemProvider != null) statusItemProvider.dispose();
		if (statusesItemProvider != null) statusesItemProvider.dispose();
		if (taskItemProvider != null) taskItemProvider.dispose();
		if (tassooItemProvider != null) tassooItemProvider.dispose();
		if (typeItemProvider != null) typeItemProvider.dispose();
		if (typesItemProvider != null) typesItemProvider.dispose();
	}

}
